﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using KPIS.GERP.GBMS.BLL;
using KPIS.GERP.GBMS.MODEL;

namespace KPIS.GERP.GBMS.APP_UI.UserControls
{
    public partial class BGM_ProjectOption : System.Web.UI.UserControl
    {
        private IProject projectBLL;
        private OptionTypeBLL optionTypeBLL = new OptionTypeBLL();

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void LoadUserControlData(string strOptionTypeSeq, string strProjSeq, string ProjType)
        {
            if (strOptionTypeSeq.Length > 0)
            {
                projectBLL = Project_Factory.GetProjectFactory(ProjType);
                IList<OptionTypeInfo> optionTypeInfoList = optionTypeBLL.Search(Convert.ToInt32(strOptionTypeSeq));
                btnDetail.OnClientClick = "openProjectOptionDetails(@1)".Replace("@1", strOptionTypeSeq);

                ((Label) btnDetail.FindControl("lblOptionTypeName")).Text = optionTypeInfoList[0].Name;
                gridOption.Columns[0].HeaderText = optionTypeInfoList[0].Name;

                gridOption.DataSource = projectBLL.GetDataProjectOption(strProjSeq, strOptionTypeSeq);
                gridOption.DataBind();
            }
        }

        public bool EnableLblOptionTypeName
        {
            get
            {
                return ((Label) btnDetail.FindControl("lblOptionTypeName")).Attributes["disabled"] != "disabled" &&
                       ((Label) btnDetail.FindControl("lblOptionTypeName")).Attributes["disabled"] != "true";
            }
            set
            {
                if (value)
                    ((Label) btnDetail.FindControl("lblOptionTypeName")).Attributes.Remove("disabled");
                else
                {
                    ((Label) btnDetail.FindControl("lblOptionTypeName")).Attributes.Remove("disabled");
                    ((Label) btnDetail.FindControl("lblOptionTypeName")).Attributes.Add("disabled", "disabled");
                }
            }
        }
    }
}